<?php

/**
 * Description of HotelModelclass
 *
 * @author Mike
 */
class CommentModel extends CommonModel {
    protected $_auto = array(
        array('id','setParentApproved',3,'callback'),
        array('parent','setApproved',3,'callback'),
        array('create_time','time',1,'function'),
        array('update_time','time',2,'function'),
    );

    public function setParentApproved($id){
        $Comment = M('Comment');
        $parent = $Comment->where('id ='.$id)->getField('parent');
        $Comment->where('id ='.$parent)->setField('approved',2);//2为已回复
        return $id;
    }
    //id 即为留言本身
    public function setApproved($id){
        $Comment = M('Comment');
        $data['approved'] = 2;//表已回复
        $data['status'] = 1; //表已许可发表
        $Comment->where('id ='.$id)->data($data)->save();
        return $id;
    }

}
?>
